<template>
  <el-row class="panel-group">
    <div class="card-panel">
      <div class="card-panel-icon-wrapper icon-message" :style="hoverStyle">
        <svg-icon icon-class="message" class-name="card-panel-icon" />
      </div>
      <div style="float: left;margin-left: 1rem">
        <p style="font-size: 16px;font-weight: bold;margin: 10px 0 10px" :style="{color:resultMap[itemData.result].color}">
          {{ resultMap[itemData.result].result }}
          <span v-if="!itemData.title" style="color: #e74c3c">题目已删除</span>
          <el-link v-if="itemData.title" style="font-size: 16px;font-weight: bold" type="primary" @click="toProblem">
            {{ itemData.problemId }}-{{ itemData.title }}
          </el-link>
        </p>
        <p style="font-size: 14px">你可以点击详细信息查看用户提交的代码
          <el-link style="font-size: 14px;font-weight: bold" type="primary" @click="toCode">[详细信息]</el-link>
        </p>
      </div>
      <div class="card-panel-description">
        <div class="card-panel-text">
          {{ itemData.judgetime }}
        </div>
      </div>
    </div>
  </el-row>
</template>

<script>
import { resultMap } from '@/utils/global'

export default {
  props: {
    itemData: {
      type: Object,
      default: () => ({
        solutionId: 1,
        title: 'A+B 输入输出练习',
        result: 4,
        judgetime: '2021-04-01 13:39:54',
        problemId: 1000
      })
    }
  },
  data() {
    return {
      resultMap: resultMap,
      hoverStyle: {
        '--color': resultMap[this.itemData.result].color
      }
    }
  },
  methods: {
    toProblem() {
      this.$router.push({
        path: '/editor',
        query: { problemId: this.itemData.problemId }
      })
    },
    toCode() {
      this.$router.push({
        path: '/code',
        query: { solutionId: this.itemData.solutionId }
      })
    }
  }

}
</script>

<style lang="scss" scoped>
.panel-group {

  .card-panel {
    height: 72px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    border-color: rgba(0, 0, 0, .05);

    &:hover {
      .card-panel-icon-wrapper {
        color: #fff;
      }

      .icon-people {
        background: #40c9c6;
      }

      .icon-message {
        background: var(--color);
      }

      .icon-money {
        background: #f4516c;
      }

      .icon-shopping {
        background: #34bfa3
      }
    }

    .icon-people {
      color: #40c9c6;
    }

    .icon-message {
      color: var(--color);
    }

    .icon-money {
      color: #f4516c;
    }

    .icon-shopping {
      color: #34bfa3
    }

    .card-panel-icon-wrapper {
      float: left;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }

    .card-panel-icon {
      float: left;
      font-size: 32px;
    }

    .card-panel-description {
      float: right;
      font-weight: bold;
      margin: 26px 26px 26px 0px;

      .card-panel-text {
        line-height: 18px;
        color: rgba(0, 0, 0, 0.45);
        font-size: 16px;
        margin-bottom: 12px;
      }

      .card-panel-num {
        font-size: 20px;
      }
    }
  }
}

@media (max-width:550px) {
  .card-panel-description {
    display: none;
  }

  .card-panel-icon-wrapper {
    float: none !important;
    width: 100%;
    height: 100%;
    margin: 0 !important;

    .svg-icon {
      display: block;
      margin: 14px auto !important;
      float: none !important;
    }
  }
}
</style>
